package com.example.desinger.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.desinger.common.R;
import com.example.desinger.entity.Admins;
import com.example.desinger.mapper.AdminsMapper;
import com.example.desinger.service.AdminsService;
import org.springframework.stereotype.Service;

@Service
public class AdminsServiceImpl extends ServiceImpl<AdminsMapper, Admins> implements AdminsService {
    @Override
    public R<Admins> longByAAndP(Admins admins) {
        LambdaQueryWrapper<Admins> lambdaQueryWrapper =
                new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Admins::getAccount,admins.getAccount())
                .eq(Admins::getPassword,admins.getPassword());
        Admins one = getOne(lambdaQueryWrapper);

        if (one==null){
            return R.error("此用户不存在");
        }

        int type =  one.getType();

        if (type==1){
            return R.success(one,"此用户为超级用户");
        }else {
            return R.success(one,"此用户为老师");
        }

    }


}
